package com.rerun.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.entity.City;
import com.rerun.entity.District;
import com.rerun.entity.Province;
import com.rerun.mapper.CityMapper;
import com.rerun.mapper.DistrictMapper;
import com.rerun.mapper.ProvinceMapper;
import com.rerun.service.ProvinceService;

/**
 * The type Province service.
 */
@Service
public class ProvinceServiceImpl extends ServiceImpl<ProvinceMapper,Province> implements ProvinceService{
    /**
     * The District mapper.
     */
    @Autowired
	DistrictMapper districtMapper;
    /**
     * The City mapper.
     */
    @Autowired
	CityMapper cityMapper;
	@Override
	public List<City> getListCityByProvinceId(String provinceId) {
		EntityWrapper<City> wrapper = new EntityWrapper<>();
		wrapper.where("cityUpId={0}", provinceId);
		return cityMapper.selectList(wrapper);
	}
	@Override
	public List<District> getListDistrictByCityId(String cityId) {
		EntityWrapper<District> wrapper = new EntityWrapper<>();
		wrapper.where("districtUpId={0}", cityId);
		return districtMapper.selectList(wrapper);
	}
	@Override
	public List<District> getListDistrictByCityName(String cityName) {
		return districtMapper.selectByName(cityName);
	}
	@Override
	public List<District> getProvinceListByPname(String provinceName) {
		return cityMapper.selectByProvinceName(provinceName);
	}
	
}
